
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
// import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    roles: ['admin','editor']    // 设置该路由进入的权限，支持多个权限叠加
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '',
    component: () => import('@/layout'),
    hidden: true,
    redirect: '/redirect',
    children: [
      {
        path: '/redirect',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/ddLogin',
    component: () => import('@/views/ddLogin'),
    hidden: true
  },
  {
    path: '/wxLogin',
    component: () => import('@/views/wxLogin'),
    hidden: true
  },
  {
    path: '/flybookLogin',
    component: () => import('@/views/flybookLogin'),
    hidden: true
  },
  {
    path: '/register',
    component: () => import('@/views/login/register'),
    hidden: true
  },
  {
    path: '/license',
    component: () => import('@/views/uploadLicense'),
    hidden: true
  },
  {
    path: '/recoverpw',
    component: () => import('@/views/login/recoverpw'),
    hidden: true
  },
  {
    path: '/aiibLogin',
    component: () => import('@/views/aiibLogin'),
    hidden: true
  }, {
    path: '/deal/mt/meetingForm',
    component: () => import('@/views/deal/mt/meetingForm'),
    hidden: true
  },
  {
    path: '/deal/mt/vote/mtVoteForm',
    component: () => import('@/views/deal/mt/vote/index'),
    hidden: true
  },
  {
    path: '/act/task/processingTask',
    component: () => import('@/views/act/task/processingTask'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true
  },
  {
    path: '/designModel',
    component: () => import('@/views/system/desform/formData/designModel'),
    hidden: true
  },
  {
    path: '/onlinePageList',
    component: () => import('@/views/system/desform/release/onlinePageList'),
    hidden: true
  },
  {
    path: '/oa/hr/base/hrBaseHome',
    component: () => import('@/views/oa/hr/base/hrBaseHome'),
    hidden: true
  },
  {
    path: '/oa/resume/resumeBaseHome',
    component: () => import('@/views/oa/resume/resumeBaseHome'),
    hidden: true
  },
  {
    path: '/deal/home/dealBaseHome',
    component: () => import('@/views/deal/home/dealBaseHome'),
    hidden: true
  },
  {
    path: '/deal/financing/base/dealBaseFinancingHome',
    component: () => import('@/views/deal/financing/base/dealBaseFinancingHome'),
    hidden: true
  },
  {
    path: '/deal/gpSecurity/gpSecurityHome',
    component: () => import('@/views/deal/gpSecurity/gpSecurityHome'),
    hidden: true
  },
  {
    path: '/company/base/companyBaseHome',
    component: () => import('@/views/company/base/companyBaseHome'),
    hidden: true
  },
  {
    path: '/fund/fundBasehome',
    component: () => import('@/views/fund/home/fundBasehome'),
    hidden: true
  },
  {
    path: '/deal/mediation/mediationBaseHome',
    component: () => import('@/views/deal/mediation/mediationBaseHome'),
    hidden: true
  },
  {
    path: '/hhqy/base/hhqyBaseHome',
    component: () => import('@/views/hhqy/base/hhqyBaseHome'),
    hidden: true
  },
  {
    path: '/fund/internal/internalBaseHome',
    component: () => import('@/views/fund/internal/internalBaseHome'),
    hidden: true
  },
  {
    path: '/company/propertyCompany/propertyCompanyHome',
    component: () => import('@/views/company/propertyCompany/propertyCompanyHome'),
    hidden: true
  },
  {
    path: '/fund/property/propertyFundHome',
    component: () => import('@/views/fund/property/propertyFundHome'),
    hidden: true
  },
  {
    path: '/fund/gpBase/gpBaseHome',
    component: () => import('@/views/fund/gpBase/gpBaseHome'),
    hidden: true
  },
  {
    path: '/dragForm',
    component: () => import('@/views/system/dragForm/form'),
    hidden: true
  },
  {
    path: '/createReport',
    name: 'createReport',
    component: () => import('@/views/dev/jmf/createReport')
  },
  {
    path: '/viewReportSheet',
    name: 'viewReportSheet',
    component: () => import('@/views/dev/jmf/viewReportSheet')
  },
  {
    path: '/viewEasyReport',
    name: 'viewEasyReport',
    component: () => import('@/views/dev/jmf/viewEasyReport')
  },
  {
    path: '/previewReport',
    name: 'previewReport',
    props: true,
    component: () => import('@/views/dev/jmf/previewReport')
  },
  {
    path: '/createEasyReport',
    name: 'createEasyReport',
    props: true,
    component: () => import('@/views/dev/jmf/createEasyReport')
  },
  {
    path: '/actModelDesign',
    name: 'actModelDesign',
    meta: { title: '流程设计' },
    component: () => import('@/views/act/model/actModelDesign')
  },
  {
    path: '/designMap',
    name: 'designMap',
    meta: { title: '产业地图' },
    component: () => import('@/views/deal/report/industryMap')
  },
  {
    path: '/batchDealImport',
    name: 'batchDealImport',
    props: true,
    meta: { title: '批量添加' },
    component: () => import('@/views/deal/base/batchDealImport')
  },
  {
    path: '/SysNotice',
    name: 'SysNotice',
    props: true,
    meta: { title: '浏览器通知', id: '999' },
    component: () => import('@/views/notice/SysNotice')
  },
  {
    path: '/SysShareHome',
    name: 'SysShareHome',
    props: true,
    meta: { title: '文件分享', id: '999' },
    component: () => import('@/views/file/share/SysShareHome')
  },
  {
    path: '',
    component: () => import('@/views/system/user/profile/changePassword'),
    redirect: '/resetPassword',
    meta: { title: '修改密码' },
    hidden: true,
    name: '修改密码',
    children: [
      {
        path: '/resetPassword',
        component: () => import('@/views/system/user/profile/changePassword'),
        name: '修改密码',
        meta: { title: '修改密码' }
      }
    ]
  },
  // {
  //   path: '',
  //   component: () => import('@/layout'),
  //   redirect: '/index',
  //   meta: { title: '首页' },
  //   menuType: 'C',
  //   hidden: true,
  //   name: '首页',
  //   parentId: '0',
  //   children: [
  //     {
  //       path: '/index',
  //       component: () => import('@/views/index'),
  //       name: '首页',
  //       meta: { title: '首页', noCache: true, affix: true }
  //     }
  //   ]
  // },
  {
    path: '',
    component: () => import('@/layout'),
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: '/user/profile',
        component: () => import('@/views/system/user/profile/index'),
        name: '个人中心',
        meta: { title: '个人中心', id: '1221', noMenu: true }
      },
      {
        path: '/searchData',
        component: () => import('@/views/searchData'),
        name: '全文检索',
        meta: { title: '全文检索', id: '12321' }
      },
      {
        path: '/dict/type/data/:dictId(\\d+)',
        component: () => import('@/views/system/dict/data'),
        name: 'Data',
        meta: { title: '字典数据', icon: '' }
      },
      {
        path: 'feedback/client/feedbackBaseList',
        component: () => import('@/views/feedback/client/feedbackBaseList'),
        name: '工单反馈',
        meta: { title: '工单反馈', id: '88488' }
      },
      {
        path: '/gen',
        component: () => import('@/views/tool/gen/editTable'),
        name: 'GenEdit',
        meta: { title: '修改生成配置' }
      },
      {
        path: '/pcw',
        component: () => import('@/views/company/pcw/pcwSysTypeTabs'),
        name: 'PcwSysTabs',
        meta: { title: '修改生成配置' }
      },
      {
        path: '/job',
        component: () => import('@/views/monitor/job/log'),
        name: 'JobLog',
        meta: { title: '日志' }
      },
      {
        path: '/appStore',
        component: () => import('@/views/appStore/index'),
        name: 'appStore',
        meta: { title: 'appStore', id: 'appStore', noMenu: true }
      },
      {
        path: '/pathHandle',
        component: () => import('@/views/appStore/pathHandle'),
        name: 'pathHandle',
        meta: { title: 'pathHandle', id: 'pathHandle' }
      },
      {
        path: '/JStoreHandle',
        component: () => import('@/views/appStore/JStoreHandle'),
        name: 'JStoreHandle',
        meta: { title: 'JStoreHandle', id: 'JStoreHandle' }
      },
      {
        path: '/appStoreInstall',
        component: () => import('@/views/appStore/install'),
        name: 'install',
        meta: { title: 'install', id: 'install' }
      },
      {
        path: '/appStore/myApp',
        component: () => import('@/views/appStore/myApp'),
        name: 'myApp',
        meta: { title: 'myApp', id: 'myApp' }
      },
      {
        path: '/appStore/featured',
        component: () => import('@/views/appStore/featured'),
        name: 'featured',
        meta: { title: 'featured', id: 'featured' }
      },
      {
        path: '/qrcode',
        component: () => import('@/views/appStore/qrcode'),
        name: 'qrcode',
        meta: { title: 'qrcode', id: 'qrcode' }
      }
    ]
  },
  {
    path: '/fund/lpBase/lpBaseHome',
    component: () => import('@/views/fund/lpBase/lpBaseHome'),
    hidden: true
  },
  {
    path: '/system/dragForm/form',
    component: () => import('@/views/system/dragForm/form'),
    hidden: true
  },
  {
    path: '/fund/fundBaseSpvHome',
    name: '',
    component: () => import('@/views/fund/home/fundBaseSpvHome'),
    hidden: true
  },
  {
    path: '/error/404',
    component: () => import('@/layout'),
    hidden: true,
    redirect: '/error/404',
    children: [
      {
        path: '/error/404',
        component: () => import('@/views/error/404'),
        name: '404',
        meta: { title: '404' }
      }
    ]
  },
  {
    path: '/indicatorLogin',
    name: 'indicatorLogin',
    props: true,
    meta: { title: '数据填报', id: '999', notPass: true },
    component: () => import('@/views/deal/indicator/data/indicatorLogin.vue')
  },
  {
    path: '/dealIndicatorDataMainPublic',
    name: 'dealIndicatorDataMainPublic',
    props: true,
    meta: { title: '数据填报', id: '999', notPass: true },
    component: () => import('@/views/deal/indicator/data/dealIndicatorDataMainPublic')
  },
  {
    path: '/saas_demo/*', // saas_demo是注册子应用的activeRule
    name: 'saas_demo',
    component: () => import('@/layout'),
    hidden: true
   },
  {
   path: '/weekly/*', // saas_demo是注册子应用的activeRule
   name: 'demo',
   component: () => import('@/layout'),
   hidden: true
  },
  {
    path: '/crm/*', // saas_demo是注册子应用的activeRule
    name: 'crm',
    component: () => import('@/layout'),
    hidden: true
  },
  {
    path: '/riskControl/*',
    name: 'riskControl',
    component: () => import('@/layout'),
    hidden: true
  },
  {
    path: '/valueRealization/*', // saas_demo是注册子应用的activeRule
    name: 'valueRealization',
    component: () => import('@/layout'),
    hidden: true
  },
  {
    path: '/JStore/*',
    name: 'JStore',
    component: () => import('@/layout'),
    hidden: true
  }
  // {
  //   path: '/qrcode',
  //   component: () => import('@/views/appStore/qrcode'),
  //   name: 'qrcode',
  //   meta: { title: 'qrcode', id: 'qrcode', noMenu: true }
  // }
]

export default new Router({
  base: process.env.VUE_APP_BASE_PATH, // 默认值: “/”，应用的基路径。例如，如果整个单页应用服务在 /app/ 下，然后 base 就应该设为 “/app/”
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

// 解决VUE路由跳转出现Redirected when going from "/xxx" to "/yyy" via a navigation guard.报错
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}
